package com.example.caimogu.fragment;


import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.example.caimogu.bean.Goods;
import com.example.caimogu.businessapp.R;
import com.example.caimogu.fragmentAdapter.HistoryAdapter;
import com.example.caimogu.fragmentAdapter.MyStoreAdapter;

import java.util.ArrayList;
import java.util.List;


/**
 * Created by Caimogu on 2016/4/20.
 */
public class HistoryOrder extends Fragment {

    private Context context;
    private Button btn_getHistoryGL;
    private ListView listView;
    private HistoryAdapter historyAdapter;
    private LayoutInflater layoutInflater;

    public  HistoryOrder(Context context, LayoutInflater layoutInflater){
        this.context = context;
        this.layoutInflater = layoutInflater;
    }
    public  HistoryOrder(){

    }

    private List<Goods> goodsList=new ArrayList<Goods>();
    private  void initData() {
        //int[] ii=new int[]{R.drawable.a24,R.drawable.a9};
        for (int i = 0; i < 15; i++) {
            Goods goods = new Goods();
            goods.setName("购买者");
            goods.setInformation("购买详情.........");
            //f.setSnap(ii[i]);
            goodsList.add(goods);
        }
    }


    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.historyorder,container,false);
        initData();
        init(view);
        return view;
    }
    private void init(View view) {
        historyAdapter = new HistoryAdapter(goodsList,layoutInflater);
        listView = (ListView)view.findViewById(R.id.lv_ho_goodslist);
        listView.setAdapter(historyAdapter);
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            }
        });
        btn_getHistoryGL = (Button)view.findViewById(R.id.btn_ho_getHistorygooList);
        btn_getHistoryGL.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getHistoryGoogsList();
            }
        });
    }

    public void getHistoryGoogsList(){
        Toast.makeText(context, "getHistoryGoogsList test ", Toast.LENGTH_SHORT).show();
    }
}
